#ifndef _SQL_H
#define _SQL_H

#include "global_val.h"
#include "sqlite3.h"

#define SQL_FIEL_TYPE_INT  0
#define SQL_FIEL_TYPE_STR  1

void sql_init();
int sql_update_zb_msg(const char *table, unsigned int cmd, unsigned cmd_type);
int sql_select_msg(const char *table, int r, int c);
int sql_get_table_msg_int(const char *table, int *col, int n, int buf[][2]);
int sql_get_table_msg_str(const char *table, int *col, int n, char buf[][3][1024]);
int sql_get_table_nfield(const char *table, int *col, char *type, int n, char buf[][10][256]);
int sql_logic_table_judge(const char *table, const char *name, const char *password);
int sql_query_value_by_id(const char *table, const char *field, const int id);
int insert_line_data(const char *table, const char data_buf[][32], char type[], int len);
int update_field_value_by_id(const char *table, const char *field, const int value, const int id);
int update_field_value_by_str(const char *table, const char *field_name, const char *filed_value, const char *str_name, const char *str_value);
int update_intfield_value_by_intfield(const char *table, const char *intfield_name, const int intfield_value, const char *uintfield_name, const int uintfield_value);
int update_field_value(const char *table, const char *update_field_name, const char *update_field_value, const char update_field_type, const char *location_field_name, const char *location_field_value, const char location_field_type);
int sql_query_field_exist(const char *table, const char *field, const void *field_value, const char type);
int update_intfield_value_by_strfield(const char *table, const char *strfield_name, const char *strfiled_value, const char *intfield_name, const int intfield_value);
int sql_query_intfield_by_strfield(const char *table, const char *intfield_name, const char *strfield_name, const char *strfield_value);
int sql_query_strfield_by_strfield(const char *table, const char *qstrfield_name, char *qstrfield_value, const char *strfield_name, const char *strfield_value);
int sql_delete_line(const char *table, const char *primary_fieldname, const char *primary_fieldvalue, const char type);
int sql_update_column(const char *table, const char *col_name, const char *col_value, const char type);
int sql_get_intfield_maxvalue(const char *table, const char *fieldname);

#endif
